package com.winchain.provider.expiration.cmd;

import com.shell.bee.acct.transaction.po.AcctTxRec;
import com.shell.bee.acct.transaction.service.AcctTxRecService;
import com.shell.bee.persistence.transaction.Transaction;
import com.shell.bee.persistence.transaction.TransactionUtil;
import com.shell.framework.command.CommandContext;
import com.shell.framework.command.ICommand;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillExpDebitCreditTranCmd implements ICommand<AcctTxRec> {
	@Autowired
	private AcctTxRecService AcctTxRecService;

	public boolean execute(final CommandContext<AcctTxRec> context) throws Exception {
		TransactionUtil.execute(new Transaction() {
			public void doInTransaction() {
				List<AcctTxRec> trans = (List) context.getValue("acctTxRecs");
				for (AcctTxRec tran : trans) {
					BillExpDebitCreditTranCmd.this.AcctTxRecService.save(tran);
				}
			}
		}, new int[0]);

		return false;
	}
}
